package cn.iocoder.yudao.module.member.dal.mysql.userwithdraw;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.userwithdraw.UserWithdrawDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.userwithdraw.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 提现 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface UserWithdrawMapper extends BaseMapperX<UserWithdrawDO> {

    default PageResult<UserWithdrawDO> selectPage(UserWithdrawPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserWithdrawDO>()
                .eqIfPresent(UserWithdrawDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserWithdrawDO::getWithdraw, reqVO.getWithdraw())
                .eqIfPresent(UserWithdrawDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(UserWithdrawDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserWithdrawDO::getId));
    }

    Integer totalWithdrawByStatus(@Param("status") Integer status);

    Integer totalWithdrawByUserId(@Param("userId") Long userId);

    Integer totalWithdrawByUserIdAndStatus(@Param("userId") Long userId,
                                           @Param("status") Integer status);

}